package com.atmilan.quartz.sync.pull.daigo.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.atmilan.quartz.model.entity.daigo.DaigoProductSkuMerged;
import com.atmilan.quartz.sync.pull.daigo.mapper.DaigoProductSkuMergedMapper;
import com.atmilan.quartz.sync.pull.daigo.service.IDaigoProductSkuMergedService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hupeng
 * @since 2020-04-27
 */
@Service
@Transactional
public class DaigoProductSkuMergedServiceImpl extends ServiceImpl<DaigoProductSkuMergedMapper, DaigoProductSkuMerged>
        implements IDaigoProductSkuMergedService {
    @Autowired
    DaigoProductSkuMergedMapper daigoProductSkuMergedMapper;
    @Override
    public List<String> findAllSkuMerged(){

        List<Object> list = daigoProductSkuMergedMapper.selectObjs(new QueryWrapper<DaigoProductSkuMerged>().select(" concat(goods_id,'-',color,'-',size) "));
        return list == null? new ArrayList<String>():list.stream().map(o->o.toString()).collect(Collectors.toList());
    }

    @Override
    public void deleteAll() {
        daigoProductSkuMergedMapper.deleteAll();
    }
    
    @Override
    public void copyAll() {
        daigoProductSkuMergedMapper.deleteSkuMergedBack();
        daigoProductSkuMergedMapper.copySkuMergedBack();
    }
    
}
